package com.yl.auth.controller;


import com.yl.auth.entity.LaorenYaopin;
import com.yl.auth.entity.Yaopin;
import com.yl.auth.model.vo.LaorenYaopinVo;
import com.yl.auth.service.LaorenYaopinService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yl
 * @since 2023-06-25
 */
@RestController
@RequestMapping("/admin/auth/laoren-yaopin")
@Api(tags = "医护管理-用药计划设置")
public class   LaorenYaopinController {
    @Resource
    private LaorenYaopinService laorenYaopinService;

    /**
     * 用药计划设置
     */
    @GetMapping("/getYyjhsz/{id}")
    @ApiOperation(value = "用药计划设置")
    public Result getYyjhsz(@PathVariable @ApiParam("老人id") Long id){
        List<LaorenYaopinVo> list=laorenYaopinService.getYyjhsz(id);
        return Result.ok(list);
    }

    /**
     * 根据id回显药品信息
     */
    @ApiOperation(value = "回显药品信息")
    @GetMapping("/get/{id}")
    public Result get(@PathVariable @ApiParam("老人id") Integer id){
        Yaopin yaopin =laorenYaopinService.getyaopin(id);
        return Result.ok(yaopin);
    }

    /**
     * 修改
     * 设置服药计划
     * 设置开始时间
     * 设置停止时间
     */
    @ApiOperation(value = "设置服药计划/开始时间/停止时间")
    @PutMapping("/updateEndTime")
    public Result updateEndTime(@RequestBody Yaopin yaopin){
        laorenYaopinService.updateYaopin(yaopin);
        return Result.ok();
    }
}

